﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FileUploadASP
{
    /// <summary>
    /// Summary description for AnyTypeFileHandler
    /// </summary>
    public class AnyTypeFileHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/octet-stream";
            FileUploadEntities dbContext = new FileUploadEntities();
            Image i = (from ii in dbContext.Images
                       where ii.ID == 6
                       select ii).Single();

            context.Response.AddHeader("Content-Disposition", "attachment; filename=" + "pesho.xlsx" + ";");
            context.Response.OutputStream.Write(i.FileBytes, 0, i.FileBytes.Length);

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}